package com.vichat.common.vo;

public class PageFilter implements java.io.Serializable {

	private int page;// 当前页
	private int rows;// 每页显示记录数
	private int offset;//查询起点
	private int limit;//查询的行数
	private String sort;// 排序字段
	private String order;// asc/desc

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}
	


	public static PageFilter getMaxPageFilter(){
        PageFilter pf = new PageFilter();
        pf.page= 1;
        pf.rows=Integer.MAX_VALUE;
		pf.limit=Integer.MAX_VALUE;
        return pf;
    }

	/**
	 * 拼装排序字段
	 * @param pf
	 * @return
	 */
	public static String orderHql(PageFilter pf) {
		String orderString = "";
		if (pf != null) {
			if ((pf.getSort() != null) && (pf.getOrder() != null)) {
				orderString = " order by " + pf.getSort() + " " + pf.getOrder();
			}
		}
		return orderString;
	}

}
